package com.supos.progress.entity;

import com.supos.progress.util.DateUtil;

import java.io.Serializable;
import java.util.Date;

/**
 */
public class CycleDate implements Serializable {
    private static final long serialVersionUID = 3685007502638041852L;
    private String startDate;
    private String endDate;
    private String toEndDatetime;
    private long toEndDateTimestamp;

    public CycleDate() {
    }

    public CycleDate(String startDate, String endDate) {
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getToEndDatetime() {
        if (toEndDatetime == null || "".equals(toEndDatetime)){
            return DateUtil.dateDiff(DateUtil.formatDateTime(new Date()), DateUtil.formatDate(DateUtil.addDateDay(DateUtil.parseDate(endDate), 1)) + " 00:00:00", DateUtil.FORMAT_DATETIME);
        }
        return toEndDatetime;
    }

    public void setToEndDatetime(String toEndDatetime) {
        this.toEndDatetime = toEndDatetime;
    }

    public long getToEndDateTimestamp() {
        return DateUtil.dateDiffTimestamp(DateUtil.formatDateTime(new Date()), DateUtil.formatDate(DateUtil.addDateDay(DateUtil.parseDate(endDate), 1)) + " 00:00:00", DateUtil.FORMAT_DATETIME);
    }

    public void setToEndDateTimestamp(long toEndDateTimestamp) {
        this.toEndDateTimestamp = toEndDateTimestamp;
    }
}
